#include <iostream>

using namespace std;

void swap(int &a, int &b)
{
	int i = a;
	a = b;
	b = i;
}

void SelectSort(int *arr, int n, size_t sz)
{
	if (n < 0)
		return;
	SelectSort(arr, n-1,sz);
	int Temp = n;
	for (int k = Temp + 1; k < sz; ++k)
	{
		if (arr[Temp] > arr[k])
			Temp = k;
	}
	swap(arr[n], arr[Temp]);

}

int main()
{
	int arr1[] = { 3, 2, 1, 5, 4 };
	SelectSort(arr1, 4, 5);//数组，元素下标，元素个数
	for (auto T : arr1)
		cout << T << endl;
	return 0;
}
